﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <%@include file="common/manage-head.jsp" %>

</head>

<body>
<div id="wrapper">

    <%@include file="common/manage-header.jsp" %>

    <div id="page-wrapper">
        <div id="page-inner">

            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-header">
                        Jurisdiction Manage
                        <small>权限管理</small>
                    </h1>
                </div>
            </div>
            <!-- /. ROW  -->

            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <button type="button" class="btn btn-primary" onclick="addAdminFun()" data-toggle="modal" data-target="#addAdminModal">新增管理员</button>
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th>用户名</th>
                                        <th>权限等级</th>
                                        <th>登录状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${pageInfo.list}" var="admin">
                                        <tr class="odd gradeX">
                                            <td>${admin.userName}</td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${admin.userLevelId == 1}">系统管理员</c:when>
                                                    <c:when test="${admin.userLevelId == 2}">文章管理员</c:when>
                                                </c:choose>
                                            </td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${admin.userState == 0}"><div class="text-success">启用</div></c:when>
                                                    <c:when test="${admin.userState == 1}"><div class="text-warning">禁用</div></c:when>
                                                </c:choose>
                                            </td>
                                            <td>
                                                <button type="button" class="btn btn-sm btn-success" onclick="adminFun('${admin.userId}')" data-toggle="modal" data-target="#adminModal">查看</button>
                                                <button type="button" class="btn btn-sm btn-primary" onclick="updateAdminPasswordFun('${admin.userId}', '${admin.userName}')" data-toggle="modal" data-target="#updateAdminPasswordModal">重置密码</button>
                                                <button type="button" class="btn btn-sm btn-danger" onclick="deleteAdminFun('${admin.userId}')" data-toggle="modal" data-target="#deleteAdminModal">删除</button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>

            <!-- 分页信息 -->
            <div class="row text-center">
                当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                <nav aria-label="Page navigation">
                    <ul class="pagination">
                        <li><a href="/adminManage/adminList?pn=1">首页</a></li>
                        <c:if test="${pageInfo.hasPreviousPage }">
                            <li>
                                <a href="/adminManage/adminList?pn=${pageInfo.pageNum-1 }" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                        </c:if>

                        <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                            <c:if test="${page_Num == pageInfo.pageNum }">
                                <li class="active"><a href="#">${page_Num }</a></li>
                            </c:if>
                            <c:if test="${page_Num != pageInfo.pageNum }">
                                <li><a href="/adminManage/adminList?pn=${page_Num }">${page_Num }</a></li>
                            </c:if>
                        </c:forEach>
                        <c:if test="${pageInfo.hasNextPage }">
                            <li>
                                <a href="/adminManage/adminList?pn=${pageInfo.pageNum+1}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </c:if>
                        <li><a href="/adminManage/adminList?pn=${pageInfo.pages}">末页</a></li>
                    </ul>
                </nav>
                <!-- 分页条结束 -->
            </div>
        </div>

        <%@include file="common/manage-foot.jsp" %>

    </div>
    <!-- /. PAGE INNER  -->
</div>
<!-- /. PAGE WRAPPER  -->
</div>
<!-- /. WRAPPER  -->

<%-- 查看 更新 --%>
<div class="modal fade" id="adminModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">管理员信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control userId hide">
                            <input type="text" class="form-control userName" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">权限等级</label>
                        <div class="col-sm-10 text-center">
                            <label class="radio-inline">
                                <input type="radio" name="userLevelId" class="userLevelId" value="1"> 系统管理员
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="userLevelId" class="userLevelId" value="2"> 文章管理员
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">登录状态</label>
                        <div class="col-sm-10 text-center">
                            <label class="radio-inline">
                                <input type="radio" name="userState" class="userState" value="0"> 启用
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="userState" class="userState" value="1"> 禁用
                            </label>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer model-button">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="updateAdminBtn">更新管理员</button>
            </div>
        </div>
    </div>
</div>

<%-- 更新密码 --%>
<div class="modal fade" id="updateAdminPasswordModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改密码</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">新密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control userPasswordReset">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">确认密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control checkUserPasswordReset">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer model-button">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="updateAdminPasswordBtn">更新密码</button>
            </div>
        </div>
    </div>
</div>

<%-- 添加 --%>
<div class="modal fade" id="addAdminModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">友链信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control addUserName">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">新密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control addUserPassword">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">确认密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control checkAddUserPassword">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">权限等级</label>
                        <div class="col-sm-10 text-center">
                            <label class="radio-inline">
                                <input type="radio" name="addUserLevelId" class="addUserLevelId" value="1" checked> 系统管理员
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="addUserLevelId" class="addUserLevelId" value="2"> 文章管理员
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">登录状态</label>
                        <div class="col-sm-10 text-center">
                            <label class="radio-inline">
                                <input type="radio" name="addUserState" class="addUserState" value="0" checked> 启用
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="addUserState" class="addUserState" value="1"> 禁用
                            </label>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer model-button">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="addUserBtn">新增管理员</button>
            </div>
        </div>
    </div>
</div>

<%-- 删除 --%>
<div class="modal fade" id="deleteAdminModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">系统提示:</h4>
            </div>
            <div class="modal-body">
                本次操作将永久性删除该数据
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-danger" id="deleteAdminBtn">删除</button>
            </div>
        </div>
    </div>
</div>

<%@include file="common/manage-scripts.jsp" %>

</body>

</html>